<?php
use mdm\admin\components\MenuHelper;
$assign_menus = MenuHelper::getAssignedMenu(Yii::$app->user->id);
function initMenu($menus,$isIcon=true){
    if(!empty($menus) && is_array($menus)){
        $m = $arr = [];
        foreach($menus as $k=>$v){
            if($isIcon){
                $data = (isset($v['data']) && !empty($v['data'])) ? json_decode($v['data'],true) : '';
                $m[$k]['icon']  = $data&&$data['icon'] ? $data['icon'] : '';
            }
            $m[$k]['label']  = $v['label'];
            $m[$k]['items'] = (isset($v['items'])&&!empty($v['items'])) ? initMenu($v['items'],false) : null;
            $m[$k]['url'] = $v['url'];
        }
        return $m;
    }
}
?>
<aside class="main-sidebar">

    <section class="sidebar">


        <?= dmstr\widgets\Menu::widget(
            [
                'options' => ['class' => 'sidebar-menu'],
                'items' => initMenu($assign_menus),/*[
                    ['label' => 'Menu Yii2', 'options' => ['class' => 'header']],
                    ['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/admin/user']],
                    ['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/admin/route']],
                    ['label' => 'Login', 'url' => ['site/login'], 'visible' => Yii::$app->user->isGuest],
                    [
                        'label' => 'Same tools',
                        'icon' => 'share',
                        'url' => '#',
                        'items' => [
                            ['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'],],
                            ['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug'],],
                            [
                                'label' => 'Level One',
                                'icon' => 'circle-o',
                                'url' => '#',
                                'items' => [
                                    ['label' => 'Level Two', 'icon' => 'circle-o', 'url' => '#',],
                                    [
                                        'label' => 'Level Two',
                                        'icon' => 'circle-o',
                                        'url' => '#',
                                        'items' => [
                                            ['label' => 'Level Three', 'icon' => 'circle-o', 'url' => '#',],
                                            ['label' => 'Level Three', 'icon' => 'circle-o', 'url' => '#',],
                                        ],
                                    ],
                                ],
                            ],
                        ],
                    ],
                ],*/
            ]
        ) ?>

    </section>

</aside>
